home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Treccani Italiana Di Scienze Lettere Ed Arti
/
[Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso
/
pc
/
data
/
xxi_appendice_dvd.swf
/
scripts
/
__Packages
/
CPrint.as
< prev
next >
Wrap
Text File
|
2007-11-08
|
9KB
|
247 lines
class CPrint extends mx.core.UIObject
{
var mFooter = "<span class=\"s_Header\">© 2007 Copyright Istituto della Enciclopedia Italiana fondata da Giovanni Treccani</span>";
var mHeader = "<span class=\"s_Header\">Enciclopedia Italiana di Scienze, Lettere ed Arti</span>";
var mTextFieldOverHeight = 4;
var mPrintIntervalId = 0;
var mTopMargin = 48;
var mImageLeftMargin = 16;
var mBottomMargin = 36;
var mPrintFontSize = 12;
var mPrintTextLeading = 5;
function CPrint()
{
super();
this._visible = false;
this.mPrinting = false;
this.doLater(this,"init");
}
function init(Void)
{
this.mShowAlert = true;
this.mPrinting = false;
this.mTextFieldOverHeight = 4;
this.txt_PrintHeader.html = true;
this.txt_PrintHeader.multiline = true;
this.txt_PrintHeader.embedFonts = _global.gUseEmbeddedFont;
this.txt_PrintHeader.styleSheet = _global.gStyleManager.GetPrintCSS();
this.txt_PrintTitle.html = true;
this.txt_PrintTitle.multiline = true;
this.txt_PrintTitle.embedFonts = _global.gUseEmbeddedFont;
this.txt_PrintTitle.styleSheet = _global.gStyleManager.GetPrintCSS();
this.txt_PrintBody.html = true;
this.txt_PrintBody.multiline = true;
this.txt_PrintBody.autoSize = false;
this.txt_PrintBody.embedFonts = _global.gUseEmbeddedFont;
this.txt_PrintBody.styleSheet = _global.gStyleManager.GetPrintCSS();
this.txt_PrintFooter.html = true;
this.txt_PrintFooter.multiline = true;
this.txt_PrintFooter.embedFonts = _global.gUseEmbeddedFont;
this.txt_PrintFooter.styleSheet = _global.gStyleManager.GetPrintCSS();
this.mPrintFontSize = 12;
this.mPrintTextLeading = 5;
this.mLineHeight = this.mPrintFontSize + this.mPrintTextLeading;
this.mPrintTextFormat = new TextFormat();
this.mPrintTextFormat.size = this.mPrintFontSize;
this.mPrintTextFormat.leading = this.mPrintTextLeading;
this.mPrintIntervalId = 0;
}
function PrintImage(inTitleHtml, inDidaHtml, inImageUrl)
{
this.txt_PrintHeader.htmlText = this.mHeader;
this.txt_PrintFooter.htmlText = this.mFooter;
this.txt_PrintTitle.htmlText = inTitleHtml;
this.txt_PrintBody.htmlText = inDidaHtml;
this.mc_PrintImage.__set__contentPath(inImageUrl);
this.mc_PrintImage._visible = true;
this.txt_PrintTitle._visible = true;
this.txt_PrintBody.scroll = 0;
this.mPrintIntervalId = setInterval(this,"doPrintImage",400);
}
function doPrintImage()
{
if(this.mc_PrintImage.__get__percentLoaded() < 100)
{
return undefined;
}
if(this.mPrintIntervalId)
{
clearInterval(this.mPrintIntervalId);
}
this.mPrintIntervalId = 0;
var _loc2_ = new PrintJob();
if(_loc2_.start() != true)
{
return undefined;
}
var _loc3_ = _loc2_.pageWidth;
var _loc4_ = _loc2_.pageHeight;
this.SetupHeaderFooter(_loc3_,_loc4_);
this.txt_PrintTitle._width = _loc3_;
this.txt_PrintTitle._height = this.txt_PrintTitle.textHeight + this.mTextFieldOverHeight;
this.txt_PrintTitle._x = 0;
var _loc8_ = Math.max(this.mTopMargin,this.txt_PrintHeader._height + 12);
this.txt_PrintTitle._y = _loc8_;
this.txt_PrintBody._width = _loc3_;
this.txt_PrintBody._height = this.txt_PrintBody.textHeight + this.mTextFieldOverHeight;
this.txt_PrintBody._x = 0;
var _loc10_ = Math.max(this.mBottomMargin,this.txt_PrintFooter._height + 12);
var _loc7_ = _loc4_ - _loc10_ - this.txt_PrintBody._height;
this.txt_PrintBody._y = _loc7_;
var _loc6_ = _loc8_ + this.txt_PrintTitle._height + 12;
var _loc11_ = _loc7_ - 12;
var _loc5_ = _loc11_ - _loc6_;
if(_loc5_ < 100)
{
}
this.mc_PrintImage._x = this.mImageLeftMargin;
this.mc_PrintImage._y = _loc6_;
this.mc_PrintImage.setSize(_loc3_ - 2 * this.mImageLeftMargin,_loc5_);
var _loc9_ = {xMin:0,xMax:_loc3_,yMin:0,yMax:_loc4_};
if(_loc2_.addPage(this,_loc9_))
{
_loc2_.send();
}
false;
_loc2_ = undefined;
}
function PrintHtml(inHeaderHtml, inHtml)
{
this.mShowAlert = true;
if(this.mPrinting == true)
{
return undefined;
}
if(this.mShowAlert == true)
{
_global.gAlert.ShowAlert("","Stampa in corso","EMPTY",10);
updateAfterEvent();
}
this.mHeaderHtml = inHeaderHtml;
this.mHtml = inHtml;
this.doLater(this,"DoPrintHtml_wait");
}
function DoPrintHtml_wait()
{
this.doLater(this,"DoPrintHtml");
}
function DoPrintHtml()
{
var _loc2_ = this.mHeaderHtml;
this.mHeaderHtml = "";
var _loc3_ = this.mHtml;
this.mHtml = "";
if(this.mPrintIntervalId)
{
clearInterval(this.mPrintIntervalId);
}
this.mPrintIntervalId = 0;
this.mc_PrintImage._visible = false;
if(_loc2_ == undefined)
{
_loc2_ = "";
}
this.txt_PrintHeader.htmlText = this.mHeader + "<br>" + _loc2_;
this.txt_PrintFooter.htmlText = this.mFooter;
if(_loc3_ == undefined)
{
_loc3_ = "";
}
this.txt_PrintTitle.htmlText = "";
this.txt_PrintTitle._visible = false;
this.txt_PrintBody.htmlText = _loc3_;
this.txt_PrintBody.setTextFormat(this.mPrintTextFormat);
this.txt_PrintBody.scroll = 0;
this.mPrintIntervalId = setInterval(this,"doPrint",500);
}
function doPrint()
{
if(this.mPrintIntervalId)
{
clearInterval(this.mPrintIntervalId);
}
this.mPrintIntervalId = 0;
var _loc5_ = new PrintJob();
if(_loc5_.start() != true)
{
if(this.mShowAlert)
{
_global.gAlert.Hide();
}
this.mPrinting = false;
return undefined;
}
var _loc10_ = _loc5_.pageWidth;
var _loc8_ = _loc5_.pageHeight;
this.SetupHeaderFooter(_loc10_,_loc8_);
this.txt_PrintTitle._visible = false;
var _loc9_ = Math.max(this.txt_PrintHeader._height,this.mTopMargin);
var _loc15_ = _loc8_ - Math.max(this.mBottomMargin,this.txt_PrintFooter._height + 12);
this.txt_PrintBody._width = _loc10_;
this.txt_PrintBody._height = Math.floor((_loc15_ - _loc9_) / this.mLineHeight) * this.mLineHeight;
this.txt_PrintBody._x = 0;
this.txt_PrintBody._y = _loc9_;
var _loc4_ = 0;
var _loc14_ = 0;
var _loc12_ = _loc5_.pageWidth - 20;
var _loc13_ = 0;
var _loc11_ = _loc8_;
var _loc6_ = {xMin:_loc14_,xMax:_loc12_,yMin:_loc13_,yMax:_loc11_};
if(_loc5_.addPage(this,_loc6_))
{
_loc4_ = _loc4_ + 1;
}
while(this.txt_PrintBody.bottomScroll < this.txt_PrintBody.maxscroll)
{
this.txt_PrintBody.scroll = this.txt_PrintBody.bottomScroll + 1;
if(_loc5_.addPage(this,_loc6_))
{
_loc4_ = _loc4_ + 1;
}
}
if(this.txt_PrintBody.scroll < this.txt_PrintBody.maxscroll)
{
var _loc7_ = "";
var _loc3_ = 0;
while(_loc3_ < this.txt_PrintBody.bottomScroll - this.txt_PrintBody.maxscroll + 10)
{
_loc7_ += "<br>";
_loc3_ = _loc3_ + 1;
}
this.txt_PrintBody.htmlText += _loc7_;
this.txt_PrintBody.scroll = this.txt_PrintBody.bottomScroll + 1;
if(_loc5_.addPage(this,_loc6_))
{
_loc4_ = _loc4_ + 1;
}
}
if(_loc4_ > 0)
{
_loc5_.send();
}
false;
_loc5_ = undefined;
this.txt_PrintBody.htmlText = "";
if(this.mShowAlert)
{
_global.gAlert.Hide();
}
this.mPrinting = false;
}
function SetupHeaderFooter(printWidth, printHeight)
{
this.mc_PrintBkg._width = printWidth;
this.mc_PrintBkg._height = printHeight;
this.mc_PrintBkg._x = this.mc_PrintBkg._y = 0;
this.txt_PrintHeader._width = printWidth;
this.txt_PrintHeader._x = this.txt_PrintHeader._y = 0;
this.txt_PrintFooter._width = printWidth;
this.txt_PrintFooter._height = this.txt_PrintFooter.textHeight + this.mTextFieldOverHeight;
this.txt_PrintFooter._x = 0;
this.txt_PrintFooter._y = printHeight - this.txt_PrintFooter._height;
}
function Destroy()
{
}
}